<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html>
<head>
    <meta charset="utf-8">
    <title>编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css" media="all">
    <link rel="stylesheet" href="css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-container">

    <div class="layui-form layuimini-form" th:object="${fdetail}">
        <input type="hidden" th:field="*{id}">
        <input type="hidden" th:field="*{name}">
        <input type="hidden" th:field="*{time}">
        <input type="hidden" th:field="*{picture}">
        <input type="hidden" th:field="*{u_id}">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label required">反馈信息</label>
            <div class="layui-input-block">
                <textarea th:field="*{content}" readonly="readonly" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label required">联系邮件</label>
            <div class="layui-input-block">
                <input type="email" th:field="*{email}" readonly="readonly" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text" >
            <label class="layui-form-label required">反馈图片</label>
            <div class="layui-input-block">
                <img class="layui-upload-img" width="550px" height="300px" id="demo1" name="msg" th:src="*{'feedbackPictures/'+picture}"/>
            </div>
        </div>
<!--        <span th:if="(*{state} eq '未查看' ) or (*{state} eq '未解决')">-->
            <div class="layui-form-item layui-form-text" th:if="(*{state} eq '未查看' ) or (*{state} eq '未解决')">
                <label class="layui-form-label required">是否解决</label>
<!--                <div class="layui-input-block">-->
<!--                    <input type="radio" name="已解决" value="已解决" title="是" checked="">-->
<!--                    <input type="radio" name="未解决" value="未解决" title="否">-->
<!--                </div>-->
                <div class="layui-input-block">
                    <select name="state" lay-verify="">
                        <option value="已解决">已解决</option>
                        <option value="未解决">未解决</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item" th:if="(*{state} eq '未查看' ) or (*{state} eq '未解决')">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">提交</button>
                    <button class="layui-btn layui-btn-primary" lay-submit lay-filter="cancelBtn">取消</button>
                </div>
            </div>
<!--        </span>-->
    </div>

</div>
<script src="layui/layui.js" type="text/javascript" charset="UTF-8"></script>
<script src="js/jquery-3.6.3.js"></script>
<script>
    //当页面一加载时就向后台发送post请求,获取当前用户的姓名


    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var userData = data.field;
            $.ajax({
                type: 'POST',
                url: window.location.protocol + '//' + window.location.host + '/ApprovalFeedback',
                dataType: 'html',
                data: JSON.stringify(userData),
                contentType: 'application/json',
                success: function (data) {
                    // 关闭弹出层
                    if (data){
                        parent.layer.msg("提交成功");
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        parent.layui.table.reload('currentTableId');
                        // window.location.reload();
                    }else {
                        layer.msg("服务器异常，请稍后重试！");
                    }

                },
                error: function () {
                    //console.log(data);
                    layer.close(registerLoadIndex);
                    layer.alert("请求超时！")
                }
            });
            return false;
        });

        form.on('submit(cancelBtn)', function () {
            $('.layui-textarea').val('');
            parent.layer.closeAll();
           return false;
        });

    });
</script>
</body>
</html>